import React, { Component } from 'react'
import PropTypes from 'prop-types'

class Item extends Component {

    state = {
        flag: true
    }

    static defaultProps = {
        name: 'Strange'
    }

    // static PropTypes = {
    //     item: PropTypes.any.isRequired
    // }

    clickBtn() {
        this.setState({
            flag: !this.state.flag
        })
    }

    render() { 
        let { item } = this.props
        let { flag } = this.state
        return (
            <div className='item' onClickCapture={() => {
                this.clickBtn()
            }}>
                <span className={flag ? 'active1' : 'active2'}>x</span>
                <img src={item.img} alt='' />
                <h5>{item.title}</h5>
                <button className={flag ? 'active1' : 'active2'}>编辑</button>
            </div>
        )
    }
}

// Item.PropTypes = {
//     item: PropTypes.any.isRequired
// }
 
export default Item;